import * as sdk from './fetch';

const controllerName = 'investigationController';

/**
 *
 * 获取问卷列表
 *
 */
async function findInvestList(params): Promise<BaseResponseString> {
  let result = await sdk.rzget(
    `investigation/findInvestList?pageNum=${params.pageNum}&userId=${params.userId}&scope=${params.scope}`,
    {}
  );
  return result;
}
/**
 *
 * 获取问卷答案
 *
 */
async function findUserDetail(params): Promise<BaseResponseString> {
  let result = await sdk.rzget(
    `investigation/findUserDetail?userId=${params.userId}&id=${params.id}`,
    {}
  );
  return result;
}
/**
 *
 * 问卷提交
 *
 */
async function addAnswer(params): Promise<BaseResponseString> {
  let result = await sdk.rzpost(
    'investigation/addAnswer',
    {
      ...params
    }
  );
  return result;
}


export default {
  findInvestList,
  findUserDetail,
  addAnswer,
};

/**
 * 正常请求返回
 */
export interface BaseResponseString {
  /**
   * 结果码
   */
  code: string;
  /**
   * 内容
   */
  data?: {
    [k: string]: any;
  };
  /**
   * 错误内容
   */
  errorData?: {
    [k: string]: any;
  };
  /**
   * 状态
   */
  success?: boolean;
  /**
   * 消息内容
   */
  message?: string;
  [k: string]: any;
}
